package com.twu.biblioteca;

import org.junit.Test;
import java.io.*;

import static org.junit.Assert.*;

public class testApp {
   @Test
    public void test(){
       String [] username={"111-1111","111-1112","111-1113","111-1114","111-1115"};
       String [] name= {"Anuja","Dilip","Parth","Aditi","Suman"};
       String [] pwd={"abc","def","ghi","jkl","mno"};
       String [] emailID={"u1@gmail.com","u2@gmail.com","u3@gmail.com","u4@gmail.com","u5@gmail.com"};
       String [] phno ={"9807767676","9434122321","9023104511","8140067811","8066732109"};

       String [] movName = {"The Godfather","The Forrest Gump","The Shawshank Redemption","The Green Mile",
               "Avatar","The Pursuit of Happyness","Million Dollar Baby","Cast Away","A Beautiful Mind",
               "Life of Pi","Inception","Pulp Fiction","Gladiator","Schindler's List","The Curious Case of Benjamin Button"};
       int [] yr={1972,1994,1994,1999,2009,2006,2004,2000,2001,2012,2010,1994,2000,1993,2008};
       String [] dir={"Francis Ford Coppola","Robert Zemeckis","Frank Darabont","Frank Darabont","James Cameron",
               "Gabriele Muccino","Clint Eastwood","Robert Zemeckis","Ron Howard","Ang Lee","Christopher Nolan",
               "Quentin Tarantino","Ridley Scott","Steven Spielberg","David Fincher"};
       String [] rating ={"9","8","N/A","7","9","N/A","8","9","9","8","N/A","N/A","8","9","7"};
       User u[]= new User[5];
       Movie m[]=new Movie[15];

       BibliotecaApp b=new BibliotecaApp();

        assertEquals(b.bookPresent("Gone with the wind"), 0);  //Gone with the wind is not available
        assertEquals(b.bookPresent("Don Quixote"),1);    //Don Quixote is present in the books list
        assertTrue(b.bookPresent("The Kite Runner")==1);     //The Kite Runner is present
        assertNotNull(b.BookNames);     //Books list is not empty
       for(int i=0;i<5;i++)
       {
           u[i]=new User(username[i],name[i],pwd[i],emailID[i],phno[i]);
       }
       for(int i=0;i<15;i++)
       {
           m[i]=new Movie(movName[i],yr[i],dir[i],rating[i]);
       }
       assertEquals(b.checkUserList(u, "111-1118", "ghi"), null);      //user not registered
       assertNotEquals(b.checkUserList(u, "111-1111", "abc"), null);   //user registered
       assertNotEquals(b.moviePresent(m,"The Green Mile"),-1);         //Movie available in library
       assertEquals(b.moviePresent(m,"Spiderman II"),-1);         //Movie not available in the library
    }
}
